package com.propic.www;

import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.PasswordField;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;

/**
 * Created by geange on 16-5-14.
 */
public class RenamePane {

    private static String filename = null;

    public static Stage rename(){
        Stage stage = new Stage();
        GridPane gridPane = new GridPane();
        gridPane.setPadding(new Insets(40, 0, 0, 50));
        gridPane.setHgap(5); gridPane.setVgap(5);

        Scene scene = new Scene(gridPane, 300, 150);

        Label lbUser = new Label("修改图片名:");
        GridPane.setHalignment(lbUser, HPos.RIGHT);
        TextField tfUser = new TextField();

        tfUser.setStyle("-fx-background-radius: 2em; "+
                "-fx-min-height: 25px; " +
                "-fx-max-height: 25px;"
        );


        Button btLogin = new Button("重命名");

        btLogin.setStyle("-fx-background-radius: 2em; ");

        btLogin.setOnAction(changename->{
            filename = tfUser.getText();
            RenamePane tmp = new RenamePane();
            if (!Mainwindows.copyfile.isEmpty()){
                Rename renameall = new Rename();
                renameall.renameMany(Mainwindows.copyfile, filename);
            }
            System.out.println(filename);
            stage.close();
        });
        GridPane.setMargin(btLogin, new Insets(10, 0, 0, 0));

        gridPane.add(lbUser, 0, 0);
        gridPane.add(tfUser, 1, 0);

        gridPane.add(btLogin, 1, 2);

        stage.setTitle("重命名");
        stage.setScene(scene);


        return stage;
    }

    public static String getFilename(){
        return filename;
    }


    public static void main(String args[]){
//        RenamePane tmp = new RenamePane();

    }
}
